package com.star.security.authentication.usernamepassword;

import com.star.security.authentication.AuthenticationToken;
import lombok.Getter;
import lombok.Setter;

/**
 * 用户名密码验证
 *
 * @author yangzj
 */
@Setter
@Getter
public class UsernamePasswordAuthenticationToken extends AuthenticationToken {

    public UsernamePasswordAuthenticationToken(Object principal, Object credentials, Object details, Long expiresIn, Boolean multiEndpoint) {
        super(principal, credentials, details, expiresIn, multiEndpoint);
    }

    /**
     * 未经验证
     *
     * @param principal   用户名
     * @param credentials 密码
     * @param expiresIn   有效时间（秒）
     * @return {@link UsernamePasswordAuthenticationToken}
     */
    public static UsernamePasswordAuthenticationToken unauthenticated(Object principal, Object credentials, Object details, long expiresIn, boolean multiEndpoint) {
        return new UsernamePasswordAuthenticationToken(principal, credentials, details, expiresIn, multiEndpoint);
    }


    /**
     * 已验证
     *
     * @param principal 用户信息
     * @param expiresIn 有效时间（秒）
     * @return {@link UsernamePasswordAuthenticationToken}
     */
    public static UsernamePasswordAuthenticationToken authenticated(Object principal, long expiresIn, boolean multiEndpoint) {
        return new UsernamePasswordAuthenticationToken(principal, null, null, expiresIn, multiEndpoint);
    }

}
